
package com.wdh.kjs.Adapter;



import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wdh.kjs.R;
import com.wdh.kjs.model.Question;

import java.util.ArrayList;


public class QuestionListViewAdapter2 extends BaseAdapter{

	Context mContext;
	LayoutInflater mInflater;
	ArrayList<Question> questionList;

	public QuestionListViewAdapter2(Context context, ArrayList<Question> questionList){
		this.mContext=context;
		this.mInflater=LayoutInflater.from(context);
		this.questionList=questionList;
	}
	
	@Override
	public int getCount() {
		 if(questionList==null){
			 return 0;
		 }else{
			 return questionList.size();
		 }
	}

	@Override
	public Object getItem(int position) {
	   if(questionList==null ){
		return null;
	   }else{
		   return questionList.get(position);
	   }
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder  viewHolder;
		if(convertView==null){
			convertView=mInflater.inflate(R.layout.kefu_question_item2, null);
			viewHolder=new ViewHolder();
			viewHolder.questionDescirbe=(TextView)convertView.findViewById(R.id.question_msg2);
			convertView.setTag(viewHolder);
		}else{
			viewHolder=(ViewHolder)convertView.getTag();
		}
		Question question=(Question)getItem(position);
		viewHolder.questionDescirbe.setText(question.getQuestionDescribe());
		return convertView;
	}
	class ViewHolder{
		TextView questionDescirbe;//问题的描述
	}
}